<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>会员信息查询</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入 Bootstrap Table CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.21.1/dist/bootstrap-table.min.css" rel="stylesheet">
    <!-- 引入外部自定义样式 -->
    <link href="./css/select.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <h1 class="text-center mb-4">会员信息查询画面</h1>

    <!-- 查询表单 -->
    <div class="card p-4 mb-4 shadow-sm">
        <form class="row g-3">
            <div class="col-md-6">
                <label for="idInput" class="form-label">编号</label>
                <input type="text" class="form-control" id="idInput" placeholder="请输入编号">
            </div>
            <div class="col-md-6">
                <label for="phoneInput" class="form-label">手机号</label>
                <input type="text" class="form-control" id="phoneInput" placeholder="请输入手机号">
            </div>
            <div class="col-12 d-flex justify-content-between mt-3">
                <button type="submit" class="btn btn-primary">搜索</button>
                <a href="insert.html" class="btn btn-success">添加</a>
            </div>
        </form>
    </div>

    <!-- 数据表格 -->
    <table
            id="table"
            data-toggle="table"
            data-search="true"
            data-pagination="true"
            data-show-columns="true"
            data-toolbar="#toolbar"
            class="table table-hover table-bordered align-middle">
        <thead class="table-dark">
        <tr>
            <th data-field="id">#</th>
            <th data-field="code">编号</th>
            <th data-field="name">名字</th>
            <th data-field="score">积分</th>
            <th data-field="phone">手机号</th>
            <th data-field="gender">性别</th>
            <th data-field="action">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>1</td>
            <td>1001</td>
            <td>小红</td>
            <td>200</td>
            <td>13399990000</td>
            <td>男</td>
            <td>
                <a href="update.html" class="btn btn-sm btn-warning me-2" onclick="editRow(this)">修改</a>
                <a href="delete.html" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        <tr>
            <td>2</td>
            <td>1002</td>
            <td>小利</td>
            <td>300</td>
            <td>13399990001</td>
            <td>女</td>
            <td>
                <a href="update.html" class="btn btn-sm btn-warning me-2" onclick="editRow(this)">修改</a>
                <a href="delete.html" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        <tr>
            <td>3</td>
            <td>1003</td>
            <td>小明</td>
            <td>400</td>
            <td>13399990002</td>
            <td>男</td>
            <td>
                <a href="update.html" class="btn btn-sm btn-warning me-2" onclick="editRow(this)">修改</a>
                <a href="delete.html" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        <tr>
            <td>4</td>
            <td>1004</td>
            <td>小黑</td>
            <td>500</td>
            <td>13399990003</td>
            <td>女</td>
            <td>
                <a href="update.html" class="btn btn-sm btn-warning me-2" onclick="editRow(this)">修改</a>
                <a href="delete.html" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        <tr>
            <td>5</td>
            <td>1005</td>
            <td>小刘</td>
            <td>600</td>
            <td>13399990004</td>
            <td>男</td>
            <td>
                <a href="update.html" class="btn btn-sm btn-warning me-2" onclick="editRow(this)">修改</a>
                <a href="delete.html" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<!-- 引入 Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- 引入 Bootstrap Table JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.21.1/dist/bootstrap-table.min.js"></script>

<script>
    function editRow(button) {
        // 获取当前行的所有单元格数据
        var row = $(button).closest('tr');
        var cells = row.find('td');

        // 提取每个单元格的数据并存储在变量中
        var id = parseFloat(cells.eq(0).text());
        var code = parseFloat(cells.eq(1).text());
        var name = parseFloat(cells.eq(2).text());
        var score = parseFloat(cells.eq(3).text());
        var phone = parseFloat(cells.eq(4).text());
        var gender = parseFloat(cells.eq(5).text());

        // 将数据存储到localStorage
        localStorage.setItem('id', id);
        localStorage.setItem('code', code);
        localStorage.setItem('name', name);
        localStorage.setItem('score', score);
        localStorage.setItem('phone', phone);
        localStorage.setItem('gender', gender);

        window.location.href = "update.html";
    }
</script>
</body>
</html>
